﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WriteToEventLog
{
    class Program
    {
        static void Main(string[] args)
        {
            using (System.Diagnostics.EventLog appLog = new System.Diagnostics.EventLog())
            {
                appLog.Source = "EventLogAddEventsTest";
                appLog.Log = "Application";
                appLog.WriteEntry("EventLogAddEventsTest", System.Diagnostics.EventLogEntryType.Error, 7026, 1);
                appLog.Close();
                System.Threading.Thread.Sleep(1000);
            }

            //// & does not match the eventlogname
            //using (System.Diagnostics.EventLog cbns3 = new System.Diagnostics.EventLog())
            //{
            //    cbns3.Source = "NotSystem";
            //    cbns3.Log = "NotSystem";
            //    cbns3.WriteEntry("the search expression does not mtch.", System.Diagnostics.EventLogEntryType.Error, 7026, 1);
            //    cbns3.Close();
            //}

            //using (System.Diagnostics.EventLog wareDrv = new System.Diagnostics.EventLog())
            //{
            //    wareDrv.Source = "testing123";
            //    wareDrv.Log = "Application";
            //    wareDrv.WriteEntry("abcdeFg", System.Diagnostics.EventLogEntryType.Error, 7026, 1);
            //    wareDrv.Close();
            //}
        }
    }
}
